using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace WozLib.UI.Containers
{
  enum WozSizeableType
  {
    SizeableWindow,
    SizeableCanvas,
    SizeableInkCanvas
  }

  public class WozSizeable
  {
    private Window _Window;

    private Canvas _Canvas;

    private InkCanvas _InkCanvas;

    private WozSizeableType _WozSizeableType;

    public WozSizeable(Window window)
    {
      _WozSizeableType = WozSizeableType.SizeableWindow;
      _Window = window;
    }

    public WozSizeable(Canvas canvas)
    {
      _WozSizeableType = WozSizeableType.SizeableCanvas;
      _Canvas = canvas;
    }

    public WozSizeable(InkCanvas inkCanvas, Window window)
    {
      _WozSizeableType = WozSizeableType.SizeableInkCanvas;
      _InkCanvas = inkCanvas;
      _Window = window;
    }

    public WozSizeable(InkCanvas inkCanvas)
    {
      _WozSizeableType = WozSizeableType.SizeableInkCanvas;
      _InkCanvas = inkCanvas;
    }

    public string Title
    {
      get
      {
        if (_Window != null)
        {
          return _Window.Title;
        }
        else
        {
          return "";
        }
      }
      set
      {
        if (_Window != null)
        {
          _Window.Title = value;
        }
      }
    }

    public double Width
    {
      get 
      {
        switch (_WozSizeableType)
        {
          case WozSizeableType.SizeableWindow:
            return _Window.Width;
          case WozSizeableType.SizeableCanvas:
            return _Canvas.Width;
          case WozSizeableType.SizeableInkCanvas:
            return _InkCanvas.Width;
          default:
            return 0.0;
        }
      }
      set
      {
        switch (_WozSizeableType)
        {
          case WozSizeableType.SizeableWindow:
            _Window.Width = value;
            break;
          case WozSizeableType.SizeableCanvas:
            _Canvas.Width = value;
            break;
          case WozSizeableType.SizeableInkCanvas:
            _InkCanvas.Width = value;
            break;
        }
      }
    }

    public double Height
    {
      get
      {
        switch (_WozSizeableType)
        {
          case WozSizeableType.SizeableWindow:
            return _Window.Height;
          case WozSizeableType.SizeableCanvas:
            return _Canvas.Height;
          case WozSizeableType.SizeableInkCanvas:
            return _InkCanvas.Height;
          default:
            return 0.0;
        }
      }
      set
      {
        switch (_WozSizeableType)
        {
          case WozSizeableType.SizeableWindow:
            _Window.Height = value;
            break;
          case WozSizeableType.SizeableCanvas:
            _Canvas.Height = value;
            break;
          case WozSizeableType.SizeableInkCanvas:
            _InkCanvas.Height = value;
            break;
        }
      }
    }
	
  }
}
